import random
from cal_time import cal_time

@cal_time
def bubble_sort(li):
    n=len(li)-1
    #第i趟
    for i in range(n):
        exchange=False
        for j in range(n-i):
            if li[j]>li[j+1]: #升序排列是大于，降序排列是小于
                li[j],li[j+1]=li[j+1],li[j]
                exchange = True
        if not exchange:
            return

li=list(range(10000))
random.shuffle(li)
bubble_sort(li)

